import axios from '@/libs/api.request'

export const getEnvNames = (val) => {
  return axios.request({
    url: 'api/HttpAutoTestService/environment/names/',
    params: val,
    method: 'get'
  })
};

export const getEnvs = (val) => {
  return axios.request({
    url: 'api/HttpAutoTestService/environments/',
    params: val,
    method: 'get'
  })
};

export const createEnv = (env) => {
  return axios.request({
    url: 'api/HttpAutoTestService/environment/',
    data: env,
    method: 'post'
  })
};

export const deleteEnv = (id) => {
  return axios.request({
    url: `api/HttpAutoTestService/environment/${id}/`,
    method: 'delete'
  })
};

export const partialUpdateEnv = (data) => {
  const id = data.id;
  delete data.id;
  return axios.request({
    url: `api/HttpAutoTestService/environment/${id}/`,
    data: data,
    method: 'patch'
  })
};

export const updateEnv = (env) => {
  return axios.request({
    url: `api/HttpAutoTestService/environment/${env.id}/`,
    data: env,
    method: 'put'
  })
};
